import { Button, message, Popconfirm } from 'antd';
import React, { Children } from 'react';
import {DeleteOutlined} from '@ant-design/icons'

const Del =function(props){
  const {isuse,remove,itemId,children} = props
  //用itemId的长度判断是批量删除还是删除单个
  const confirm = (e) => {
    if(itemId.length<=1){
      remove(itemId[0])
    }else{
      remove(itemId)
    }
  };
  const cancel = (e) => {
    message.error('操作失败');
  };
  return(
    <Popconfirm
      title="您确定删除吗？"
      onConfirm={confirm}
      onCancel={cancel}
      okText="确定"
      cancelText="取消"
      disabled={isuse}
    >
      <Button danger style={{marginRight:'10px'}} disabled={isuse}><DeleteOutlined />{children}</Button>
    </Popconfirm>
  )
};

export default Del;